package com.sjl.db137.controller;

import com.sjl.db137.config.R;
import com.sjl.db137.entity.Menu;
import com.sjl.db137.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0
 * @Author sjl
 * @date 2024/12/30 09:01
 * @Description 菜单相关
 */
@RestController
@CrossOrigin(origins = "*")
public class MenuController {
    @Autowired
    MenuService menuService;

    /***
     * 获取所有的菜单
     * @return
     */
    @GetMapping("selectmenu")
    public R selectMenu(){

        List<Menu> menuList = this.menuService.list();//获取所有的菜单
        return new R().add("menuList", menuList);
    }

    @GetMapping("selectmenubyid/{id}")
    public R selectMenuById(@PathVariable int id){
        Menu menu = this.menuService.getById(id);

        return new R().add("menu", menu);
    }
}











































